//
//  NewPassController.m
//  NoNameAmazing
//
//  Created by liuyang on 2017/9/29.
//  Copyright © 2017年 北京执行力科技有限公司. All rights reserved.
//

#import "NewPassController.h"
#import "LoginViewController.h"
@interface NewPassController ()
@property (weak, nonatomic) IBOutlet UITextField *nwPassField;
@property (weak, nonatomic) IBOutlet UITextField *reNewField;
@property (weak, nonatomic) IBOutlet UIButton *sureBtn;

@end

@implementation NewPassController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColorFromRGB(0xEFEFF5);
    
}
- (IBAction)sureBtnClick:(id)sender {
    if( ![self.nwPassField.text isEqualToString:self.reNewField.text]){
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"新密码两次输入不一样"
                                                                       message:nil
                                                                preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction* action = [UIAlertAction actionWithTitle:@"确定"
                                                         style:UIAlertActionStyleDefault
                                                       handler:nil];
        [alert addAction:action];
        [self presentViewController:alert animated:YES completion:nil];

    }else{
        [self requestClick];
        
    }

}

-(void)requestClick
{
    NSDictionary *params = @{@"accountname":self.name,
                             @"newpass":_nwPassField.text,
                             @"yzm":self.codeStr
                             };
    [NetWorkManager requestWithType:1 withUrlString:@"/password/newpassword.do" withParaments:params withSuccessBlock:^(id object) {
        
        if ([object[@"status"]intValue]==1 ) {
            LoginViewController *loginController = [[LoginViewController alloc]init];
            [self.view.window setRootViewController:loginController];
        }
        
    } withFailureBlock:^(NSError *error) {
        
        
    } progress:^(float progress) {
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
